
$(document).ready(function () {
/*™*******************************************************************************************™*/


	
	 $( "#BTTnewrow" ).click(function() {
	 
    	
		var num_row = $("#HIDnum_row").val();


		num_row = parseFloat(num_row) + parseFloat(1);
		$("#HIDnum_row").val(num_row);
		
		var req = getXMLHTTP(); // fuction to get xmlhttp object
	     if (req)
	     {
	      req.onreadystatechange = function()
	     {
	      if (req.readyState == 4) { //data is retrieved from server
	       if (req.status == 200) { // which reprents ok status                    
	         document.getElementById('city'+num_row).innerHTML=req.responseText;
	      }
	      else
	      { 
	         alert("There was a problem while using XMLHTTP:\n");
	      }
	      }            
	      }        
	    req.open("GET", "province", true); //open url using get method
	    req.send(null);
	     }
		
        

		$("<p><label for='province'>Branch Province:</label></p><div id='city"+num_row+"'></div><p><label for='district'>Branch District:</label><select class='form-control' name='district_sub[]' id='district"+num_row+"'><option value=''>------Please Select-------</option></select></p>").insertBefore("#addNewRow");
			
		
		

    });
    
    
   
    
    

});
 



	function getXMLHTTP() { //fuction to return the xml http object
        var xmlhttp=false;    
        try{
            xmlhttp=new XMLHttpRequest();
        }
        catch(e)    {        
            try{            
                xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(e){
                try{
                req = new ActiveXObject("Msxml2.XMLHTTP");
                }
                catch(e1){
                    xmlhttp=false;
                }
            }
        }

        return xmlhttp;
    }
    
    
     
    function selectDis(value)
    {  
    
    	
	    var num_row = $("#HIDnum_row").val();
	    
	    
	    
	    var req = getXMLHTTP(); // fuction to get xmlhttp object
		     if (req)
		     {
		      req.onreadystatechange = function()
		     {
		      if (req.readyState == 4) { //data is retrieved from server
		       if (req.status == 200) { // which reprents ok status                    
		         document.getElementById('district'+num_row).innerHTML=req.responseText;
		      }
		      else
		      { 
		         alert("There was a problem while using XMLHTTP:\n");
		      }
		      }            
		      }        
		    req.open("GET", "district_sub/"+value, true); //open url using get method
		    req.send(null);
		     }
	    
    
    }
    


    function getcate(strURL)
    {       
 
     var req = getXMLHTTP(); // fuction to get xmlhttp object
     if (req)
     {
      req.onreadystatechange = function()
     {
      if (req.readyState == 4) { //data is retrieved from server
       if (req.status == 200) { // which reprents ok status                    
         document.getElementById('citydiv').innerHTML=req.responseText;
      }
      else
      { 
         alert("There was a problem while using XMLHTTP:\n");
      }
      }            
      }        
    req.open("GET", strURL, true); //open url using get method
    req.send(null);
     }
    }


 
   
    

